

package com.wake.widget.widget.dialog;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;

import androidx.annotation.Nullable;

import com.wake.widget.R;
import com.wake.widget.layout.NMUIConstraintLayout;

/**
 * Created by wake on 2021/2/28.
 */

public class NMUIDialogView extends NMUIConstraintLayout {


    private OnDecorationListener mOnDecorationListener;

    public NMUIDialogView(Context context) {
        this(context, null);
    }

    public NMUIDialogView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public NMUIDialogView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        setId(R.id.nmui_dialog_layout);
    }

    public void setOnDecorationListener(OnDecorationListener onDecorationListener) {
        mOnDecorationListener = onDecorationListener;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (mOnDecorationListener != null) {
            mOnDecorationListener.onDraw(canvas, this);
        }
    }

    @Override
    public void dispatchDraw(Canvas canvas) {
        super.dispatchDraw(canvas);
        if (mOnDecorationListener != null) {
            mOnDecorationListener.onDrawOver(canvas, this);
        }
    }

    public interface OnDecorationListener {
        void onDraw(Canvas canvas, NMUIDialogView view);

        void onDrawOver(Canvas canvas, NMUIDialogView view);
    }
}
